<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="800px"
    @close="resetForm"
  >
    <el-form ref="ruleForm" :model="formData" :rules="rules" label-width="100px" class="demo-ruleForm">
      <el-form-item label="状态" prop="money">
        <el-radio-group v-model="formData.status">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="-1">不通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="descri">
        <el-input v-model="formData.descri" type="textarea" rows="4" placeholder="备注" clearable />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="verifyOne('ruleForm')">提交</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      title: '新增记录',
      dialogVisible: false,
      formData: {
        recharge_id: '',
        status: '',
        descri: ''
      },
      rules: {
        status: [
          { required: true, message: '请选择状态', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    show(row) {
      if (row) {
        this.formData = {
          recharge_id: row.id,
          status: row.status,
          descri: ''
        }
      }
      this.dialogVisible = true
    },
    hide() {
      this.dialogVisible = false
    },
    verifyOne(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('verifyOne', this.formData)
          this.dialogVisible = false
          this.resetForm()
        } else {
          console.log(valid)
        }
      })
    },
    resetForm() {
      this.formData = {
        recharge_id: '',
        status: '',
        descri: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
